// 默认导入
import axios from 'axios'
// url的全局设置
axios.defaults.baseURL = 'http://api-toutiao-web.itheima.net/'
// 请求拦截器
axios.interceptors.request.use(function (config) {
  const tokenStr = localStorage.getItem('tokenStr')
  if (tokenStr) {
    config.headers.Authorization = `Bearer ${tokenStr}`
  }
  return config
}, function (error) {
  return Promise.reject(error)
})
export default axios
